package base.btn {
	import base.btn.BtnHit;
	import flash.display.Sprite;
	import base.btn.BtnHitEvent;
	import com.greensock.TweenLite;
	import com.greensock.easing.Quad;
	
	public class BtnClose extends BtnHit {
		
		public var cross: Sprite;
		public static var COUNT_FRAMES_MOUSE_OVER_OUT: uint = 10;
		
		public function BtnClose(): void {
			this.addEventListener(BtnHitEvent.OVER, this.onOverHandler);
			this.addEventListener(BtnHitEvent.OUT, this.onOutHandler);
		}
		
		protected function setElementsOutOver(isOutOver: uint): void {
			var targetScale: Number = [1, 0.7][isOutOver];
			TweenLite.killTweensOf(this.cross);
			TweenLite.to(this.cross, BtnClose.COUNT_FRAMES_MOUSE_OVER_OUT, {scaleX: targetScale, scaleY: targetScale, rotation: [-360, 360][isOutOver], useFrames: true, ease: Quad.easeInOut});
		}
		
		private function onOverHandler(event: BtnHitEvent): void {
			this.setElementsOutOver(1);
		}
		
		private function onOutHandler(event: BtnHitEvent): void {
			this.setElementsOutOver(0);
		}
		
	}

}